package com.csce.domain.entity.exam.vo;

import cn.hutool.json.JSONUtil;
import com.doudou.core.container.ListUtil;
import com.doudou.core.lang.ObjUtil;
import lombok.*;

import java.util.List;

/**
 * @author zzx
 * @since 2023-08-02
 */
@AllArgsConstructor
@NoArgsConstructor
@Data
@Builder
@ToString
public class ExExamQuestion {

    /**
     * 可以是ExExercise的主键也时刻是ExExamde的主键
     */
    private Long examId;
    /**
     * 题目编号
     */
    private Long questionId;
    /**
     * 是否做对 1 对  2不对
     */
    private Integer isRight;
    /**
     * 答案id集合
     */
    private List<Long> answers;

    public String getAnswers() {
        return answers.toString();
    }

    public void setAnswers(Object answers) {
        if (ObjUtil.isNotEmpty(answers) && JSONUtil.isTypeJSONArray(answers.toString())) {
            this.answers = JSONUtil.toList(answers.toString(), Long.class);
        } else {
            this.answers = ListUtil.list(false);
        }
    }
}
